Mastering Bitcoin, 3E (for True Epub) by Andreas M. Antonopoulos and David A. Harding
Author:Andreas M. Antonopoulos and David A. Harding
Language: eng
Format: epub
Publisher: O'Reilly Media, Inc.
Published: 2023-02-22T00:00:00+00:00
Bitcoin Core Application Programming Interface (API)
Bitcoin Core implements a JSON-RPC interface that can also be accessed using the command-line helper bitcoin-cli. The command line allows us to experiment interactively with the capabilities that are also available programmatically via the API. To start, invoke the help command to see a list of the available Bitcoin Core RPC commands:
$ bitcoin-cli help +== Blockchain == getbestblockhash getblock "blockhash" ( verbosity ) getblockchaininfo ... walletpassphrase "passphrase" timeout walletpassphrasechange "oldpassphrase" "newpassphrase" walletprocesspsbt "psbt" ( sign "sighashtype" bip32derivs finalize )
Each of these commands may take a number of parameters. To get additional help, a detailed description, and information on the parameters, add the command name after help. For example, to see help on the getblockhash RPC command:
$ bitcoin-cli help getblockhash getblockhash height Returns hash of block in best-block-chain at height provided. Arguments: 1. height (numeric, required) The height index Result: "hex" (string) The block hash Examples: > bitcoin-cli getblockhash 1000 > curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getblockhash", "params": [1000]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
At the end of the help information you will see two examples of the RPC command, using the bitcoin-cli helper or the HTTP client curl. These examples demonstrate how you might call the command. Copy the first example and see the result:
$ bitcoin-cli getblockhash 1000 00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09
The result is a block hash, which is described in more detail in the following chapters. But for now, this command should return the same result on your system, demonstrating that your Bitcoin Core node is running, is accepting commands, and has information about block 1000 to return to you.
In the next sections we will demonstrate some very useful RPC commands and their expected output.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
International Integration of the Brazilian Economy by Elias C. Grivoyannis(74643)
The Radium Girls by Kate Moore(11619)
Turbulence by E. J. Noyes(7700)
Nudge - Improving Decisions about Health, Wealth, and Happiness by Thaler Sunstein(7241)
The Black Swan by Nassim Nicholas Taleb(6762)
Rich Dad Poor Dad by Robert T. Kiyosaki(6174)
Pioneering Portfolio Management by David F. Swensen(6078)
Man-made Catastrophes and Risk Information Concealment by Dmitry Chernov & Didier Sornette(5646)
Zero to One by Peter Thiel(5488)
Secrecy World by Jake Bernstein(4388)
Millionaire: The Philanderer, Gambler, and Duelist Who Invented Modern Finance by Janet Gleeson(4092)
The Age of Surveillance Capitalism by Shoshana Zuboff(3983)
Skin in the Game by Nassim Nicholas Taleb(3965)
The Money Culture by Michael Lewis(3846)
Bullshit Jobs by David Graeber(3826)
Skin in the Game: Hidden Asymmetries in Daily Life by Nassim Nicholas Taleb(3720)
The Dhandho Investor by Mohnish Pabrai(3560)
The Wisdom of Finance by Mihir Desai(3523)
Blockchain Basics by Daniel Drescher(3327)
